package com.sunwayworld.basemodule.rm.equipment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.equipment.dao.LimsEquipmentMaintainDao;
import com.sunwayworld.basemodule.rm.equipment.bean.LimsEquipmentMaintainBean;
import com.sunwayworld.basemodule.rm.equipment.service.LimsEquipmentMaintainService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsEquipmentMaintainServiceImpl implements LimsEquipmentMaintainService {

    @Autowired
    private LimsEquipmentMaintainDao limsEquipmentMaintainDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsEquipmentMaintainDao getDao() {
        return limsEquipmentMaintainDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsEquipmentMaintainBean limsEquipmentMaintain = jsonWrapper.parseUnique(LimsEquipmentMaintainBean.class);
        limsEquipmentMaintain.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsEquipmentMaintain);
        return limsEquipmentMaintain.getId();
    }

}
